package com.leonzhangxf.spel.beandefinition.xml;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

/**
 * The demonstrate for Expression in BeanDefinition.
 *
 * @author leonzhangxf
 * @date 20190426
 */
@Configuration
@ComponentScan({"com.leonzhangxf.spel.beandefinition.xml"})
@ImportResource({"classpath:beandefinition.xml"})
public class ApplicationForExpressionInBeanDefinitionXmlStarter {

    public static void main(String[] args) {
        System.setProperty("user.region", "zh-CN");

        AnnotationConfigApplicationContext applicationContext =
            new AnnotationConfigApplicationContext(ApplicationForExpressionInBeanDefinitionXmlStarter.class);

        NumberGuess numberGuess = applicationContext.getBean(NumberGuess.class);
        System.out.println(numberGuess.getRandomNumber());

        TaxCalculator taxCalculator = applicationContext.getBean(TaxCalculator.class);
        System.out.println(taxCalculator.getDefaultLocale());

        ShapeGuess shapeGuess = applicationContext.getBean(ShapeGuess.class);
        System.out.println(shapeGuess.getInitialShapeSeed());
    }
}
